home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Over 1,000 Windows 95 Programs
/
Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso
/
1257
/
cpp2spx.c_
/
cpp2spx.c
Wrap
C/C++ Source or Header
|
1997-04-18
|
100KB
|
2,364 lines
/* EasyCODE(C++) V5.1 02.03.1995 18:05:35 */
/* EasyCODE O
If=vertical
LevelNumbers=no
LineNumbers=no
ScreenFont=Courier New,,80,9220,-11,0,400,0,0,0,0,0,0,3,2,1,49
PrinterFont=Courier New,,80,17414,-34,0,400,0,0,0,0,0,0,3,2,1,49
LastLevelId=183 */
/* EasyCODE ( 1
cpp2spx.c */
/* EasyCODE ( 155
Includes, macros, global variables */
// ********** Include header files ************
#include "conv.h"
#include "c_filt.h"
#include "tabledef.h"
#include <stdio.h>
#include <string.h>
// ********** Definition of error messages ***********
#define ERR_DOWHILE "Unexpected EOF: DoWhile not closed"
#define ERR_KEYWORD "Illegal keyword"
#define ERR_CLASS "Unexpected EOF: Class not closed"
#define ERR_CCASEBRANCH "Unexpected EOF: CCaseBranch not closed"
#define ERR_DEFAULT "Unexpected EOF: Default not closed"
#define ERR_RETURN_1 "Line=... expected"
#define ERR_RETURN_2 "Unexpected EOF: Return not closed"
#define ERR_EOF "Unexpected EOF"
#define ERR_NO_KEYWORD "No keyword in line"
#define ERR_COMMENT1 "Comment not closed"
#define ERR_COMMENT2 "Unexpected end of comment"
#define USAGEMSG "Usage: %s inputfile outputfile [/l=<int>] [/c]\n"
// ********** Function declarations **********
void convert(int key_nr, long Begin, long End,int line_begin, long* d_Begin, long* d_End,
int default_line, int *next_key);
void C_ReadLine( char msg[]);
void control_open_file (char *in_file, char *out_file, char *prog_name);
int find_options (char comment[], char level[], char input[], char output[], char *prog_name);
// ********** Variables declarations **********
FILE *infile, *outfile;
// Input/output files
BOOL bInBlockOrLevelOrFunction;
// Flag indicating unmodified line numbers
BOOL bComment;
// Flag indicating comment filter
char i_buf[I_BUFSIZE];
// Variable for content of line without keyword
char delimiter[2];
char result[I_BUFSIZE + MAX_KEYWORDLEN + 2];
// Variable for lines containing several text parts
int line_nr, level_nr, depth;
// Variables for line number, level number, maximum level depth
int no_next_key = NO_KEYWORD;
// Variable indicating no new keyword calling convert().
int *inReturn;
// Variable for calling CommentFilter indicating comment processing
/* EasyCODE ) */
/* EasyCODE ( 151
C_ReadLine */
/* EasyCODE F */
void C_ReadLine( char msg[])
/************************************************************************************
** Function: C_ReadLine
** Parameter: Error message
** Purpose: Read next line, count line numbers. If error occurs print
** error message and terminate program.
************************************************************************************/
{
if ((ReadLine(inbuf, infile))
// Call to read function successful?
)
{
err_msg(++line_nr, msg); // Print error message and terminate
exit(1);
}
else
{
line_nr++; // Increment line number
}
}
/* EasyCODE ) */
/* EasyCODE ( 152
convert */
/* EasyCODE F */
void convert(int key_nr, long Begin, long End, int line_begin, long* d_Begin, long* d_End,
int default_line, int *next_key)
/**************************************************************************************
** Function: convert
** Parameters: key_nr: Keyword ID defining further processing
** Begin: Start position in input file of constructs to
** be moved within Switch
** End: End position in input file of constructs to
** be moved within Switch
** line_begin: Line number of constructs to be moved
** d_Begin: Start position of Default in input file
** d_End: End position of Default in input file
** default_line: Line number of Default
** next_key: if next key is read ahead id is returned here
**
** Purpose: Converts C/C++ specific constructs into SPX constructs. Some keywords
** remain unmodified, some are replaced, and some are rearranged.
** Line numbers are needed for error messages.
***************************************************************************************/
{
int act_line = 0; // Actual line number
int def_line = 0; // Line number of default content
int ins_line = 0; // Line number of constructs to be inserted
int last_key;
// Last keyword before current keyword
long posBegin, posEnd;
// Start/end position of constructs (within switch) to be moved
long posNow = 0L;
// Actual file position, initialization with 0
long defaultBeginNull = 0L;
long defaultEndNull = 0L;
// File position of default
int SwitchNr = 0;
// Number of "switch" constructs, initialization with 0
result[0] = '\0';
switch (key_nr
// Further processing depends on key
)
{
case ETF_EASYCODE // Keyword: EasyCODE
:
/* EasyCODE ( 161
Replace component indicator with SPX */
/* EasyCODE :
Replace component indicator with SPX */
{
char *p = NULL;
/* EasyCODE - */
// Copy original text to result buffer
strcpy (result, inbuf);
if (// Search for delimiter in result buffer
p = strpbrk (result, "=:;"))
{
// If found go behind delimiter
// copy "SPX" and search for
// delimiter in original text
// after Keyword (must exist)
p++;
strcpy (p, "SPX");
p = strpbrk (inbuf, "=:;");
if (// Search for blank in
// original text behind
// component indicator
p = strchr (p, ' '))
{
// Append rest of text to result buffer
strcat (result, p);
}
}
// Write result buffer to file
StoreLine (result, outfile);
}
/* EasyCODE ) */
break;
case ETF_SHORTINFO // Keyword: ShortInfo
:
case ETF_ENDSHORTINFO // Keyword: EndShortInfo
:
case ETF_OPTIONS // Keyword: Options
:
case ETF_IFLAYOUT // Keyword: InLayout
:
case ETF_LEVELNUMBERS // Keyword: LevelNumbers
:
case ETF_LINENUMBERS // Keyword: LineNumbers
:
case ETF_CONSTRUCTNUMBERS // Keyword: ConstructNumbers
:
case ETF_SCREENFONT // Keyword: ScreenFont
:
case ETF_PRINTERFONT // Keyword: PrinterFont
:
case ETF_LASTLEVELID // Keyword: LastLevelId
:
case ETF_ENDOPTIONS // Keyword: EndOptions
:
case ETF_IF // Keyword: If
:
case ETF_ENDIF // Keyword: EndIf
:
case ETF_WHILE // Keyword: While
:
case ETF_ENDWHILE // Keyword: EndWhile
:
case ETF_ENDBLOCK // Keyword: EndBlock
:
case ETF_LEVELBODY // Keyword: LevelBody
:
case ETF_ENDLEVEL // Keyword: EndLevel
:
case ETF_TEXT // Keyword: Text
:
case ETF_FOR // Keyword: For
:
case ETF_ENDFOR // Keyword: EndFor
:
StoreLine( inbuf, outfile);
// All keywords before remain unchanged and are written
// to the output file.
break;
case ETF_LEVEL // Keyword: Level
:
case ETF_BLOCK // Keyword: Block
:
StoreLine( inbuf, outfile);
bInBlockOrLevelOrFunction = TRUE;
/* Save key and set flag to take following text in
block or level header unmodified */
break;
case ETF_LINE // Keyword: Line
:
/* EasyCODE ( 97
Line processing */
if ((! bComment) || (bInBlockOrLevelOrFunction)
/* No comment filtering or within block or level header */)
{
if (!*inReturn
// Not within Return construct
)
{
StoreLine( inbuf, outfile); // Write line unmodified
}
else
{
strcpy(result,"Line= ");
strcat(result, i_buf);
StoreLine(result, outfile);
// Write line unmodified but insert blanks after keyword
}
}
else
{
switch (CommentFilter( inReturn, outfile)
/* Call function for comment filtering */)
{
case ERROR_COMMENT /* Error in comment filtering */:
err_msg( line_nr, ERR_COMMENT2); // Error message
break;
case ERROR_EOF /* Unexpected EOF */:
err_msg( line_nr, ERR_EOF); // Error message
break;
}
}
/* EasyCODE ) */
break;
case ETF_ENDTEXT // Keyword: EndText
:
if (bInBlockOrLevelOrFunction
/* Within block, level, function, or class header */)
{
bInBlockOrLevelOrFunction = FALSE;
/* At end of text there is also the end of a block or level header;
reset flag - only relevant if comment filtering is enabled */
}
if ((bInBlockComment) || (bInLineComment)
/* Within block comment or end of line comment */)
{
err_msg( line_nr, ERR_COMMENT1);
/* Error message because comment not closed at end of text */
}
StoreLine( inbuf, outfile); // Save key EndText
break;
case ETF_DUMMY // Keyword: Dummy
:
StoreLine( inbuf, outfile); // Save key
if (bInBlockOrLevelOrFunction
/* Within block or level header */)
{
bInBlockOrLevelOrFunction = FALSE; /* Reset flag */
}
break;
case ETF_THEN // Keyword: Then
:
StoreLine( inbuf, outfile); // Save key
/* EasyCODE ( 118
Process Then branch */
C_ReadLine( ERR_EOF); // Read next line
key_nr = GetKeyword( delimiter, i_buf); // Extract keyword
while (((! depth) ? depth : ((depth - level_nr) < 0)) || (key_nr != ETF_ELSE)
// If depth limitation not enabled loop is processd until next ETF_ELSE.
// Otherwise loop is processed also if level is reached that is too deep.
)
{
if (key_nr == ETF_LEVEL
// Keyword: Level ?
)
{
level_nr += 1; // Increment level number
}
if ((! depth) || ((depth - level_nr) >= 0)
/* No depth limitation or not reached until yet */)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert actual line
}
if (depth && ((depth - level_nr) == -1) && (key_nr == ETF_LEVEL)
// If level depth limitation is reached level header remains as statement.
)
{
C_ReadLine( ERR_EOF); // Read next line
key_nr = GetKeyword( delimiter, i_buf); // Extract keyword
if (key_nr == ETF_DUMMY
// No level header ?
)
{
StoreLine( "Text;\n", outfile); // Save Text,EndText
StoreLine( "EndText;\n", outfile);
}
else
{
bInBlockOrLevelOrFunction = TRUE;
// Set flag because text is not filtered within level headers
while (key_nr != ETF_ENDTEXT
// Multiline level header
)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
C_ReadLine( ERR_EOF);
key_nr = GetKeyword( delimiter, i_buf);
// Save line, read next and get keyword
}
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert ETF_ENDTEXT
}
}
if (key_nr == ETF_ENDLEVEL
// Keyword EndLevel ?
)
{
level_nr--; // Decrement level number
}
C_ReadLine( ERR_EOF); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
}
/* EasyCODE ) */
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Process Else branch
break;
case ETF_ELSE // Keyword: Else
:
/* EasyCODE ( 120
Process Else Branch */
StoreLine( inbuf, outfile); // Save ETF_ELSE
C_ReadLine( ERR_EOF); // Save next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
while (((! depth) ? depth : ((depth - level_nr) < 0)) || (key_nr != ETF_ENDIF)
// If depth limitation not enabled loop is processd until next ETF_ENDIF.
// Otherwise loop is processed also if level is reached that is too deep.
)
{
if (key_nr == ETF_LEVEL
// Keyword: Level ?
)
{
level_nr += 1; // Increment level number
}
if ((! depth) || ((depth - level_nr) >= 0)
/* If no depth limitiation or not reached until yet, convert line */)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert line
}
if (depth && ((depth - level_nr) == -1) && (key_nr == ETF_LEVEL)
// If level depth limitation is reached level header remains as statement.
)
{
C_ReadLine( ERR_EOF); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
if (key_nr == ETF_DUMMY
// No level header ?
)
{
StoreLine( "Text;\n", outfile); // Save Text, EndText
StoreLine( "EndText;\n", outfile);
}
else
{
bInBlockOrLevelOrFunction = TRUE;
// Set flag because text is not filtered within level headers
while (key_nr != ETF_ENDTEXT
// Multiline level header
)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
C_ReadLine( ERR_EOF);
key_nr = GetKeyword( delimiter, i_buf);
// Convert actual line, read next and get keyword
}
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert EndText
}
}
if (key_nr == ETF_ENDLEVEL
// Keyword EndLevel ?
)
{
level_nr--; // Decrement level number
}
C_ReadLine( ERR_EOF); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
}
/* EasyCODE ) */
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Process EndIf
break;
case ETF_WHILEBODY // Keyword: WhileBody
:
StoreLine( inbuf, outfile);
/* EasyCODE ( 122
Process WhileBody */
C_ReadLine( ERR_EOF); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
while (((! depth) ? depth : ((depth - level_nr) < 0)) || (key_nr != ETF_ENDWHILE)
// If depth limitation not enabled loop is processd until next ETF_ENDWHILE.
// Otherwise loop is processed also if level is reached that is too deep.
)
{
if (key_nr == ETF_LEVEL
// Keyword Level ?
)
{
level_nr += 1; // Increment level number
}
if ((! depth) || ((depth - level_nr) >= 0)
/* No depth limitation or not reached until yet */)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert line
}
if (depth && ((depth - level_nr) == -1) && (key_nr == ETF_LEVEL)
// If level depth limitation is reached level header remains as statement.
)
{
C_ReadLine( ERR_EOF); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
if (key_nr == ETF_DUMMY
// No level header ?
)
{
StoreLine( "Text;\n", outfile); // Save Text, EndText
StoreLine( "EndText;\n", outfile);
}
else
{
bInBlockOrLevelOrFunction = TRUE;
// Set flag because text is not filtered within level headers
while (key_nr != ETF_ENDTEXT
// Multiline level header
)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
C_ReadLine( ERR_EOF);
key_nr = GetKeyword( delimiter, i_buf);
// Save line, read next and get keyword
}
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert EndText
}
}
if (key_nr == ETF_ENDLEVEL
// Keyword EndLevel ?
)
{
level_nr--; // Decrement level number
}
C_ReadLine( ERR_EOF); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
}
/* EasyCODE ) */
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Process EndWhile
break;
case ETF_BLOCKBODY // Schlüssel: BlockBody
:
StoreLine( inbuf, outfile);
/* EasyCODE ( 123
Process BlockBody */
C_ReadLine( ERR_EOF); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
while (((! depth) ? depth : ((depth - level_nr) < 0)) || (key_nr != ETF_ENDBLOCK)
// If depth limitation not enabled loop is processd until next ETF_ENDBLOCK.
// Otherwise loop is processed also if level is reached that is too deep.
)
{
if (key_nr == ETF_LEVEL
// Keyword Level ?
)
{
level_nr += 1; // Increment level number
}
if ((! depth) || ((depth - level_nr) >= 0)
/* No depth limitation or not reached until yet */)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert line
}
if (depth && ((depth - level_nr) == -1) && (key_nr == ETF_LEVEL)
// If level depth limitation is reached level header remains as statement.
)
{
C_ReadLine( ERR_EOF); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
if (key_nr == ETF_DUMMY
// No level header ?
)
{
StoreLine( "Text;\n", outfile);
StoreLine( "EndText;\n", outfile); // Save Text, EndText
}
else
{
bInBlockOrLevelOrFunction = TRUE;
// Set flag because text is not filtered within level headers
while (key_nr != ETF_ENDTEXT
// Multiline level header
)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
C_ReadLine( ERR_EOF);
key_nr = GetKeyword( delimiter, i_buf);
// Save line, read next and get keyword
}
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert EndText
}
}
if (key_nr == ETF_ENDLEVEL
// Keyword EndLevel ?
)
{
level_nr--; // Decrement level number
}
C_ReadLine( ERR_EOF);
key_nr = GetKeyword( delimiter, i_buf);
// Read next line and get keyword
}
/* EasyCODE ) */
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Process EndBlock
break;
case ETF_FORBODY // Keyword: ForBody
:
StoreLine( inbuf, outfile); // Save keyword ForBody
/* EasyCODE ( 125
Process ForBody */
C_ReadLine( ERR_EOF); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
while (((! depth) ? depth : ((depth - level_nr) < 0)) || (key_nr != ETF_ENDFOR)
// If depth limitation not enabled loop is processd until next ETF_ENDFOR.
// Otherwise loop is processed also if level is reached that is too deep.
)
{
if (key_nr == ETF_LEVEL
// Keyword Level ?
)
{
level_nr += 1; // Increment level number
}
if ((! depth) || ((depth - level_nr) >= 0)
/* No depth limitation or not reached until yet */
)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert line
}
if (depth && ((depth - level_nr) == -1) && (key_nr == ETF_LEVEL)
// If level depth limitation is reached level header remains as statement.
)
{
C_ReadLine( ERR_EOF); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
if (key_nr == ETF_DUMMY
// No level header ?
)
{
StoreLine( "Text;\n", outfile);
StoreLine( "EndText;\n", outfile); // Save Text, EndText
}
else
{
bInBlockOrLevelOrFunction = TRUE;
// Set flag because text is not filtered within level headers
while (key_nr != ETF_ENDTEXT
// Multiline level header
)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
C_ReadLine( ERR_EOF);
key_nr = GetKeyword( delimiter, i_buf);
// Save line, read next and get keyword
}
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert EndText
}
}
if (key_nr == ETF_ENDLEVEL
// Keyword EndLevel ?
)
{
level_nr--; // Decrement level number
}
C_ReadLine( ERR_EOF);
key_nr = GetKeyword( delimiter, i_buf);
// Read next line and get keyword
}
/* EasyCODE ) */
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Process EndFor
break;
case ETF_FUNCTIONBODY // Keyword: FunctionBody
:
StoreLine("FunctionBody;\n", outfile);
// Save new keyword: FunctionBody
/* EasyCODE ( 126
Process FunctionBody */
C_ReadLine( ERR_EOF); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
while (((! depth) ? depth : ((depth - level_nr) < 0)) || (key_nr != ETF_ENDFUNCTION)
// If depth limitation not enabled loop is processd until next ETF_ENDFUNCTION.
// Otherwise loop is processed also if level is reached that is too deep.
)
{
if (key_nr == ETF_LEVEL
// Keyword Level ?
)
{
level_nr += 1; // Increment level number
}
if ((! depth) || ((depth - level_nr) >= 0)
/* No depth limitation or not reached until yet */
)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert line
}
if (depth && ((depth - level_nr) == -1) && (key_nr == ETF_LEVEL)
// If level depth limitation is reached level header remains as statement.
)
{
C_ReadLine( ERR_EOF); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
if (key_nr == ETF_DUMMY
// No level header ?
)
{
StoreLine( "Text;\n", outfile);
StoreLine( "EndText;\n", outfile); // Save Text, EndText
}
else
{
bInBlockOrLevelOrFunction = TRUE;
// Set flag because text is not filtered within level headers
while (key_nr != ETF_ENDTEXT
// Multiline level header
)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
C_ReadLine( ERR_EOF);
key_nr = GetKeyword( delimiter, i_buf);
// Save line, read next and get keyword
}
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert EndText
}
}
if (key_nr == ETF_ENDLEVEL
// Keyword EndLevel ?
)
{
level_nr--; // Decrement level number
}
C_ReadLine( ERR_EOF);
key_nr = GetKeyword( delimiter, i_buf);
// Read next line and get keyword
}
/* EasyCODE ) */
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Process EndFunction
break;
case ETF_CLASS // Keyword: Class
:
/* EasyCODE ( 23
Process Class */
StoreLine ("Frame;\n", outfile); // Save keyword: Frame
C_ReadLine( ERR_CLASS); // Read next line
if ((key_nr = GetKeyword( delimiter, i_buf)) == ETF_DUMMY
// Keyword Dummy ?
)
{
StoreLine ("Text;\n", outfile);
StoreLine ("Line=class\n", outfile);
StoreLine ("EndText;\n", outfile);
// If there is no class header the frame header gets the name "class"
// to indicate that this is not a normal frame.
}
else
{
bInBlockOrLevelOrFunction = TRUE;
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Set flag for disabling comment filtering
// Convert class header
}
break;
/* EasyCODE ) */
case ETF_CLASSBODY // Keyword: ClassBody
:
/* EasyCODE ( 24
Process ClassBody */
StoreLine ("FrameBody;\n", outfile); // Save keyword: FrameBody
C_ReadLine( ERR_CLASS); // Read next line
if (((key_nr=GetKeyword(delimiter, i_buf)) != ETF_PUBLIC) &&
(key_nr != ETF_PRIVATE) &&
(key_nr != ETF_PROTECTED)
/* If there are other constructs (even dummy) before first
private/public/protected, they hav to be enclosed with a frame */)
{
StoreLine ("Frame;\n", outfile);
StoreLine ("Dummy;\n", outfile);
StoreLine ("FrameBody;\n", outfile);
// Save keywords: Frame, Dummy, FrameBody; Frame has no header
while (((! depth) ? depth : ((depth - level_nr) < 0)) ||
(key_nr != ETF_PROTECTED) && (key_nr != ETF_PUBLIC) &&
(key_nr != ETF_PRIVATE) && (key_nr != ETF_ENDCLASSBODY)
/* Whole content until keyword for private/public/protected or EndClassBody
are written into the frame if maximum level depth is not reached. */)
{
if (key_nr == ETF_LEVEL
// Keyword Level ?
)
{
level_nr += 1; // Increment level number
}
if ((! depth) || ((depth - level_nr) >= 0)
/* No depth limitation or not reached until yet */)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert actual line
}
if (depth && ((depth - level_nr) == -1) && (key_nr == ETF_LEVEL)
// If level depth limitation is reached level header remains as statement.
)
{
C_ReadLine( ERR_EOF); // Read next line
key_nr = GetKeyword( delimiter, i_buf); // Extract keyword
if (key_nr == ETF_DUMMY
// No level header ?
)
{
StoreLine( "Text;\n", outfile); // Save Text,EndText
StoreLine( "EndText;\n", outfile);
}
else
{
bInBlockOrLevelOrFunction = TRUE;
// Set flag because text is not filtered within level headers
while (key_nr != ETF_ENDTEXT
// Multiline level header
)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
C_ReadLine( ERR_EOF);
key_nr = GetKeyword( delimiter, i_buf);
// Save line, read next and get keyword
}
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert ETF_ENDTEXT
}
}
if (key_nr == ETF_ENDLEVEL
// Keyword EndLevel ?
)
{
level_nr--; // Decrement level number
}
C_ReadLine( ERR_CLASS); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
}
StoreLine( "EndFrameBody;\n", outfile);
StoreLine( "Text;\n", outfile);
StoreLine( "Line= \n",outfile);
StoreLine( "EndText;\n", outfile);
StoreLine( "EndFrame;\n", outfile);
// Close frame construct and save EndFrameBody, Text, Line= , EndText, EndFrame
}
while (key_nr != ETF_ENDCLASSBODY
// While keyword not EndClassBody
)
{
convert( key_nr, 0, 0,0, &defaultBeginNull,&defaultEndNull,0,next_key);
key_nr = *next_key;
// Recursive call for private/public/protected, in parameter next_key
// the read keyword is returned
}
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert EndClassBody
break;
/* EasyCODE ) */
case ETF_PUBLIC // Keyword: Public
:
/* EasyCODE ( 25
Process Public */
StoreLine ("Frame;\n", outfile);
StoreLine ("Text;\n", outfile);
StoreLine ("Line=public\n", outfile);
StoreLine ("EndText;\n", outfile);
StoreLine ("FrameBody;\n", outfile);
// Save frame with header: public;
// Frame/Text/Line=public/EndText/FrameBody
/* EasyCODE - */
C_ReadLine( ERR_CLASS); // Read next line
last_key = key_nr; // Save old keyword
while (((! depth) ? depth : ((depth - level_nr) < 0)) ||
((key_nr=GetKeyword(delimiter, i_buf)) != ETF_PUBLIC) &&
(key_nr != ETF_PRIVATE) &&
(key_nr != ETF_PROTECTED) &&
(key_nr != ETF_ENDCLASSBODY)
// If depth limitation not enabled loop is processd until next public/private/
// protected/EndClassBody. Otherwise loop is processed also if level is reached
// that is too deep.
)
{
last_key = key_nr; // Save old keyword
if (key_nr == ETF_LEVEL
// Keyword Level ?
)
{
level_nr += 1; // Increment level number
}
if ((! depth) || ((depth - level_nr) >= 0)
/* No depth limitation or not reached until yet */)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert actual line
}
if (depth && ((depth - level_nr) == -1) && (key_nr == ETF_LEVEL)
// If level depth limitation is reached level header remains as statement.
)
{
C_ReadLine( ERR_EOF); // Read next line
key_nr = GetKeyword( delimiter, i_buf); // Extract keyword
if (key_nr == ETF_DUMMY
// No level header ?
)
{
StoreLine( "Text;\n", outfile); // Save Text,EndText
StoreLine( "EndText;\n", outfile);
}
else
{
bInBlockOrLevelOrFunction = TRUE;
// Set flag because text is not filtered within level headers
while (key_nr != ETF_ENDTEXT
// Multiline level header
)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
C_ReadLine( ERR_EOF);
key_nr = GetKeyword( delimiter, i_buf);
// Save line, read next and get keyword
}
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert ETF_ENDTEXT
}
}
if (key_nr == ETF_ENDLEVEL
// Keyword EndLevel ?
)
{
level_nr--; // Decrement level number
}
C_ReadLine( ERR_CLASS); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
}
if (last_key == ETF_PUBLIC
// If old keyword was ETF_PUBLIC a dummy has to follow FrameBody
)
{
StoreLine("Dummy;\n", outfile); // Save Dummy;
}
StoreLine( "EndFrameBody;\n", outfile);
StoreLine( "Text;\n", outfile);
StoreLine( "Line= \n",outfile);
StoreLine( "EndText;\n", outfile);
StoreLine( "EndFrame;\n", outfile);
*next_key = key_nr;
// Close frame construct and save EndFrameBody, Text,
// Line= , EndText, EndFrame
// In next_key read ahead key is passed
break;
/* EasyCODE ) */
case ETF_PROTECTED // Keyword: protected
:
/* EasyCODE ( 26
Process Protected */
StoreLine ("Frame;\n", outfile);
StoreLine ("Text;\n", outfile);
StoreLine ("Line=protected\n", outfile);
StoreLine ("EndText;\n", outfile);
StoreLine ("FrameBody;\n", outfile);
// Save frame with header: protected;
/* EasyCODE - */
C_ReadLine( ERR_CLASS); // Read next line
last_key = key_nr; // Save old keyword
while (((! depth) ? depth : ((depth - level_nr) < 0)) ||
((key_nr=GetKeyword(delimiter, i_buf)) != ETF_PUBLIC) &&
(key_nr != ETF_PRIVATE) &&
(key_nr != ETF_PROTECTED) &&
(key_nr != ETF_ENDCLASSBODY)
// If depth limitation not enabled loop is processd until next public/private/
// protected/EndClassBody. Otherwise loop is processed also if level is reached
// that is too deep.
)
{
last_key = key_nr; // Save old keyword
if (key_nr == ETF_LEVEL
// Keyword Level ?
)
{
level_nr += 1; // Increment level number
}
if ((! depth) || ((depth - level_nr) >= 0)
/* No depth limitation or not reached until yet */)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert actual line
}
if (depth && ((depth - level_nr) == -1) && (key_nr == ETF_LEVEL)
// If level depth limitation is reached level header remains as statement.
)
{
C_ReadLine( ERR_EOF); // Read next line
key_nr = GetKeyword( delimiter, i_buf); // Extract keyword
if (key_nr == ETF_DUMMY
// No level header ?
)
{
StoreLine( "Text;\n", outfile); // Save Text,EndText
StoreLine( "EndText;\n", outfile);
}
else
{
bInBlockOrLevelOrFunction = TRUE;
// Set flag because text is not filtered within level headers
while (key_nr != ETF_ENDTEXT
// Multiline level header
)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
C_ReadLine( ERR_EOF);
key_nr = GetKeyword( delimiter, i_buf);
// Save line, read next and get keyword
}
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert ETF_ENDTEXT
}
}
if (key_nr == ETF_ENDLEVEL
// Keyword EndLevel ?
)
{
level_nr--; // Decrement level number
}
C_ReadLine( ERR_CLASS); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
}
if (last_key == ETF_PROTECTED
// If old keyword was ETF_PROTECTEF a dummy has to follow FrameBody
)
{
StoreLine("Dummy;\n", outfile); // Save Dummy;
}
StoreLine( "EndFrameBody;\n", outfile);
StoreLine( "Text;\n", outfile);
StoreLine( "Line= \n",outfile);
StoreLine( "EndText;\n", outfile);
StoreLine( "EndFrame;\n", outfile);
*next_key = key_nr;
// Close frame construct and save EndFrameBody, Text,
// Line= , EndText, EndFrame
// In next_key read ahead key is passed
break;
/* EasyCODE ) */
case ETF_PRIVATE // Keyword: Private
:
/* EasyCODE ( 27
Process Private */
StoreLine ("Frame;\n", outfile);
StoreLine ("Text;\n", outfile);
StoreLine ("Line=private\n", outfile);
StoreLine ("EndText;\n", outfile);
StoreLine ("FrameBody;\n", outfile);
// Save frame with header: private
/* EasyCODE - */
C_ReadLine( ERR_CLASS); // Read next line
last_key = key_nr; // Save old keyword
while (((! depth) ? depth : ((depth - level_nr) < 0)) ||
((key_nr=GetKeyword(delimiter, i_buf)) != ETF_PUBLIC) &&
(key_nr != ETF_PRIVATE) &&
(key_nr != ETF_PROTECTED) &&
(key_nr != ETF_ENDCLASSBODY)
// If depth limitation not enabled loop is processd until next public/private/
// protected/EndClassBody. Otherwise loop is processed also if level is reached
// that is too deep.
)
{
last_key = key_nr; // Save old keyword
if (key_nr == ETF_LEVEL
// Keyword Level ?
)
{
level_nr += 1; // Increment level number
}
if ((! depth) || ((depth - level_nr) >= 0)
/* No depth limitation or not reached until yet */)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert actual line
}
if (depth && ((depth - level_nr) == -1) && (key_nr == ETF_LEVEL)
// If level depth limitation is reached level header remains as statement.
)
{
C_ReadLine( ERR_EOF); // Read next line
key_nr = GetKeyword( delimiter, i_buf); // Extract keyword
if (key_nr == ETF_DUMMY
// No level header ?
)
{
StoreLine( "Text;\n", outfile); // Save Text,EndText
StoreLine( "EndText;\n", outfile);
}
else
{
bInBlockOrLevelOrFunction = TRUE;
// Set flag because text is not filtered within level headers
while (key_nr != ETF_ENDTEXT
// Multiline level header
)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
C_ReadLine( ERR_EOF);
key_nr = GetKeyword( delimiter, i_buf);
// Save line, read next and get keyword
}
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert ETF_ENDTEXT
}
}
if (key_nr == ETF_ENDLEVEL
// Keyword EndLevel ?
)
{
level_nr--; // Decrement level number
}
C_ReadLine( ERR_CLASS); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
}
if (last_key == ETF_PRIVATE
// If old keyword was ETF_PRIVATE a dummy has to follow FrameBody
)
{
StoreLine("Dummy;\n", outfile); // Save Dummy
}
StoreLine( "EndFrameBody;\n", outfile);
StoreLine( "Text;\n", outfile);
StoreLine( "Line= \n",outfile);
StoreLine( "EndText;\n", outfile);
StoreLine( "EndFrame;\n", outfile);
*next_key = key_nr;
// Close frame construct and save EndFrameBody, Text,
// Line= , EndText, EndFrame
// In next_key read ahead key is passed
break;
/* EasyCODE ) */
case ETF_ENDCLASSBODY // Keyword: EndClassBody
:
StoreLine( "EndFrameBody;\n", outfile); // Save keyword EndFrameBody
break;
case ETF_ENDCLASS // Keyword: EndClass
:
StoreLine( "EndFrame;\n", outfile); // Save keyword EndFrame
break;
case ETF_DOWHILE // Keyword: DoWhile
:
StoreLine("Repeat;\n", outfile); // Save keyword Repeat
/* EasyCODE ( 137
Process DoWhile */
C_ReadLine( ERR_EOF); // Read next line
key_nr = GetKeyword( delimiter, i_buf); // Extrahieren des Schlüsselwortes
while (((! depth) ? depth : ((depth - level_nr) < 0)) || (key_nr != ETF_UNTIL)
// If depth limitation not enabled loop is processd until next ETF_UNTIL.
// Otherwise loop is processed also if level is reached that is too deep.
)
{
if (key_nr == ETF_LEVEL
// Keyword Level ?
)
{
level_nr += 1; // Increment level number
}
if ((! depth) || ((depth - level_nr) >= 0)
/* No depth limitation or not reached until yet */)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert actual line
}
if (depth && ((depth - level_nr) == -1) && (key_nr == ETF_LEVEL)
// If level depth limitation is reached level header remains as statement.
)
{
C_ReadLine( ERR_EOF); // Read next line
key_nr = GetKeyword( delimiter, i_buf); // Extract keyword
if (key_nr == ETF_DUMMY
// No level header ?
)
{
StoreLine( "Text;\n", outfile); // Save Text,EndText
StoreLine( "EndText;\n", outfile);
}
else
{
bInBlockOrLevelOrFunction = TRUE;
// Set flag because text is not filtered within level headers
while (key_nr != ETF_ENDTEXT
// Multiline level header
)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
C_ReadLine( ERR_EOF);
key_nr = GetKeyword( delimiter, i_buf);
// Save line, read next and get keyword
}
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert ETF_ENDTEXT
}
}
if (key_nr == ETF_ENDLEVEL
// Keyword EndLevel ?
)
{
level_nr--; // Decrement level number
}
C_ReadLine( ERR_EOF); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
}
/* EasyCODE ) */
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Process Until
break;
case ETF_UNTIL // Keyword: Until
:
/* EasyCODE ( 28
Process Until */
StoreLine( inbuf, outfile); // Save line
StoreLine( "Not;\n", outfile); /* Invert do-while condition in Repeat loop */
/* EasyCODE - */
C_ReadLine( ERR_DOWHILE); // Read next line
switch (GetKeyword( delimiter, i_buf)
// Keyword
)
{
case ETF_DUMMY // Keyword: ETF_DUMMY
:
StoreLine( "Dummy;\n",outfile); // Save Dummy
break;
case ETF_TEXT // Keyword: ETF_TEXT
:
convert( ETF_TEXT,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
C_ReadLine( ERR_DOWHILE);
// Convert actual line and read next
while ((key_nr = GetKeyword( delimiter, i_buf)) == ETF_LINE
// While keyword ETF_LINE
)
{
convert( ETF_LINE,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
C_ReadLine( ERR_DOWHILE);
// Convert line and read next
}
if (key_nr == ETF_ENDTEXT
// Next keyword ETF_ENDTEXT ?
)
{
StoreLine ("EndText;\n", outfile); // Save EndText
}
else
{
err_msg(line_nr, ERR_KEYWORD);
exit(1); // Error message and termination
}
break;
default:
err_msg(line_nr, ERR_KEYWORD);
exit(1); // Error message and termination
break;
}
StoreLine( "EndNot;\n", outfile); // Save EndNot
break;
/* EasyCODE ) */
case ETF_ENDDOWHILE // Keyword: EndDoWhile
:
StoreLine("EndRepeat;\n", outfile); // Save EndRepeat
break;
case ETF_BREAK // Keyword: Break
:
StoreLine( "WhenExit;\n", outfile);
StoreLine( "Dummy;\n", outfile);
StoreLine( "EndWhenExit;\n", outfile);
// Convert Break -> WhenExit, Dummy, EndWhenExit and save keywords
break;
case ETF_CONTINUE // Keyword: Continue
:
StoreLine( "Text;\n", outfile);
StoreLine( "Line=Continue\n", outfile);
StoreLine( "EndText;\n", outfile);
// Convert Continue -> Text, Line=Continue, EndText
break;
case ETF_CSWITCH // Keyword: CSwitch
:
StoreLine("Loop;\n", outfile);
StoreLine("OnSelector;\n", outfile);
// Save keyword Loop, OnSelector
break;
case ETF_CSWITCHBODY // Keyword: CSwitchBody
:
/* EasyCODE ( 36
Process CSwitchBody */
StoreLine("OnSelectorList;\n", outfile); // Save keyword OnSelectorList
posBegin = TellPos( infile); // Save actual file pointer
C_ReadLine( ERR_CCASEBRANCH); // Read next line
if ((key_nr = GetKeyword( delimiter, i_buf)) == ETF_CCASEBRANCH
/* First case branch ? */)
{
posBegin = 0L; // Reset file position
while (key_nr != ETF_ENDCSWITCH
// While keyword not EndCSwitch
)
{
switch (key_nr
// Which keyword ?
)
{
case ETF_CCASEBRANCH // Keyword: CCaseBranch
:
while (key_nr != ETF_CCASEBRANCHBODY
// Loop to process value of CASEBRANCHES:
// TEXT/LINE/ENDTEXT or DUMMY.
)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
C_ReadLine( ERR_CCASEBRANCH);
key_nr = GetKeyword( delimiter, i_buf);
// Save line, read next and get keyword
}
convert(key_nr, posBegin, posEnd,ins_line,&defaultBeginNull,&defaultEndNull,0,next_key);
key_nr = *next_key;
// Convert CaseBranch and get next key in variable next_key
break;
case ETF_DEFAULT:
def_line = line_nr; // Save line number of default
convert ( key_nr, 0,0,0, d_Begin, d_End,0, &no_next_key);
// Call for reading default branch
C_ReadLine( ERR_CCASEBRANCH);
key_nr = GetKeyword( delimiter, i_buf);
// Read next line and get keyword
break;
default:
err_msg( line_nr, ERR_KEYWORD); // Error message and termination
exit(1);
break;
}
}
if (*d_Begin
// default branch found
)
{
convert( ETF_DEFAULT,0,0,0,d_Begin,d_End,def_line, &no_next_key);
// Convert Default
}
else
{
StoreLine("OnSelectorRest;\n",outfile);
StoreLine("OnSelectorBranch;\n", outfile);
StoreLine("Dummy;\n", outfile);
StoreLine("OnSelectorBranchBody;\n", outfile);
StoreLine("WhenExit;\n", outfile);
StoreLine("Dummy;\n", outfile);
StoreLine("EndWhenExit;\n", outfile);
StoreLine("EndOnSelectorBranch;\n", outfile);
// Save empty otherwise branch
}
convert(ETF_ENDCSWITCH, 0,0,0,&defaultBeginNull,&defaultEndNull,0, &no_next_key);
// Convert EndCSwitch
}
else
{
if (key_nr == ETF_CSWITCH
// Next construct after SwitchBody: CSwitch ?
)
{
SwitchNr += 1; // Increment Switch number
}
/* EasyCODE ( 37
Read until case branch or default branch */
posEnd = 0L; // Reset actual end position
ins_line = line_nr - 1; // Save line number
while (((key_nr != ETF_CCASEBRANCH) && (key_nr != ETF_DEFAULT)) || ( SwitchNr)
/* Read until a CCASEBRANCH is found, but only on the same level.
I.e. if there are further nested Switches, their case branches are not
recognized in this outer Switch.
Program enters read loop, if no CCASEBRANCH is read and position is
in a nested Switch. */)
{
posEnd = TellPos( infile); // Save actual file position
C_ReadLine( ERR_CCASEBRANCH); // Read next line
switch ((key_nr = GetKeyword( delimiter, i_buf))
// Further keys - to count further Switches
)
{
case ETF_CSWITCH // Keyword: CSwitch
:
SwitchNr++; // Increment Switch number
break;
case ETF_ENDCSWITCH // Keyword: EndCSwitch
:
SwitchNr -= 1; // Decrement Switch number
break;
default:
break;
}
}
if (! posEnd
// If an ETF_DEFAULT follows immediately, posEnd remains Null;
// posBegin has to be Null too.
)
{
posBegin = 0L; // Reset position begin
ins_line = 0;
}
/* EasyCODE ) */
if (key_nr == ETF_DEFAULT
// Keyword Default
)
{
def_line = line_nr; // Save line number of default
convert(ETF_DEFAULT, 0,0,0, d_Begin, d_End,0, &no_next_key);
// Read Default and save Default begin und end position
/* EasyCODE - */
C_ReadLine( ERR_CCASEBRANCH); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
switch (key_nr
// Dependent on keyword
)
{
case ETF_CCASEBRANCH // Keyword: CCaseBranch
:
while (key_nr != ETF_ENDCSWITCH
// While not EndCSwitch
)
{
while (key_nr != ETF_CCASEBRANCHBODY
// Loop for processing CCaseBranches:
// Dummy or Text/Line=../EndText
)
{
convert(key_nr, 0, 0,0,&defaultBeginNull,&defaultEndNull,0, &no_next_key);
C_ReadLine( ERR_CCASEBRANCH);
key_nr = GetKeyword( delimiter, i_buf);
// Convert line, Read next line and get keyword
}
convert( key_nr, posBegin, posEnd,ins_line,&defaultBeginNull,&defaultEndNull,0, next_key);
posBegin = 0L;
posEnd = 0L;
ins_line = 0;
key_nr = *next_key;
// Convert CaseBranchBodies. In first loop posBegin and posEnd of constructs
// to be inserted are reset. In next_key read ahead keyword is passed.
}
convert(ETF_DEFAULT,0,0,0,d_Begin,d_End,def_line,&no_next_key);
convert(key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Call convert to write Default branch
// Convert EndCSwitch
break;
case ETF_ENDCSWITCH // Keyword: EndCSwitch
:
// In this case the Switch construct only contains a Default branch
// In EasyCODE(SPX) there must be an of branch
StoreLine("OnSelectorBranch;\n", outfile);
StoreLine("Dummy;\n", outfile);
StoreLine("OnSelectorBranchBody;\n", outfile);
StoreLine("Dummy;\n", outfile);
StoreLine("EndOnSelectorBranch;\n",outfile);
convert(ETF_DEFAULT, posBegin, posEnd,ins_line, d_Begin, d_End,def_line,&no_next_key);
// Function call with keyword ETF_DEFAULT for writing
convert(key_nr, 0,0,0, &defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert ETF_ENDCSITCH
break;
default:
break;
}
}
else
{
while (key_nr != ETF_ENDCSWITCH
// Loop while EndCSwitch not read
)
{
switch (key_nr
// Dependent on keyword
)
{
case ETF_CCASEBRANCH // Keyword: CCaseBranch
:
while (key_nr != ETF_CCASEBRANCHBODY
// Loop while keyword not CCaseBranchBody
// Loop to process CCASEBRANCH, TEXT/LINE/ENDTEXT
// or DUMMY
)
{
convert(key_nr, 0, 0,0,&defaultBeginNull,&defaultEndNull,0, &no_next_key);
// Process actual line
/* EasyCODE - */
C_ReadLine( ERR_CCASEBRANCH);
key_nr = GetKeyword( delimiter, i_buf);
// Read next line and get keyword
}
convert(key_nr, posBegin, posEnd,ins_line,&defaultBeginNull,&defaultEndNull,0, next_key);
posBegin = 0L;
posEnd = 0L;
key_nr = *next_key;
// Convert actual line with keyword: CCaseBranchBody
// Only in first loop posBegin and posEnd Werte may contain values,
// because constructs may be inserted only in first CaseBranch.
// Function call delivers erad aheafd key in next_key
break;
case ETF_DEFAULT // Keyword: Default
:
def_line = line_nr; // Save line number of Default
convert ( key_nr, 0,0,0, d_Begin, d_End,0, &no_next_key);
// Call to read Default branch
C_ReadLine( ERR_CCASEBRANCH);
key_nr = GetKeyword( delimiter, i_buf);
// Read next line and get keyword
break;
default:
err_msg( line_nr, ERR_KEYWORD);
// Error message if any other keyword
break;
}
}
if (*d_Begin
// Default branch contained in Switch
)
{
convert( ETF_DEFAULT,0,0,0,d_Begin,d_End,def_line, &no_next_key);
// Function call to write keyword: Default
}
else
{
StoreLine("OnSelectorRest;\n",outfile);
StoreLine("OnSelectorBranch;\n", outfile);
StoreLine("Dummy;\n", outfile);
StoreLine("OnSelectorBranchBody;\n", outfile);
StoreLine("WhenExit;\n", outfile);
StoreLine("Dummy;\n", outfile);
StoreLine("EndWhenExit;\n", outfile);
StoreLine("EndOnSelectorBranch;\n", outfile);
// If no default branch contained an empty otherwise branch must be inserted
}
convert(ETF_ENDCSWITCH, 0,0,0,&defaultBeginNull,&defaultEndNull,0, &no_next_key);
// Convert EndCSwitch
}
}
break;
/* EasyCODE ) */
case ETF_ENDCSWITCH // Keyword: EndCSwitch
:
StoreLine("EndOnSelector;\n", outfile);
StoreLine("EndLoop;\n", outfile);
// Save EndOnSelector and EndLoop
break;
case ETF_CCASEBRANCH // Keyword: CCaseBranch
:
StoreLine("OnSelectorBranch;\n", outfile);
// Save new keyword OnSelectorBranch
break;
case ETF_CCASEBRANCHBODY // Keyword: CCaseBranchBody
:
/* EasyCODE ( 29
Process CCaseBranchBody */
StoreLine("OnSelectorBranchBody;\n", outfile); // Save new keyword: OnSelectorBranchBody
if (Begin
// Wenn Konstrukte einzufügen sind
)
{
posNow = TellPos( infile); // Sae actual file position in posNow
SeekPos( Begin, infile); // Search position of constructs to be inserted
act_line = line_nr; // Save actual line number
line_nr = line_begin; // Set line number to value of constructs to be inserted
/* EasyCODE ( 52
Insert constructs in first case branch */
while (TellPos( infile) != End
// While end of position of constructs to be inserted is not reached
)
{
C_ReadLine( ERR_CCASEBRANCH); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
if (key_nr == ETF_LEVEL
// Keyword Level ?
)
{
level_nr += 1; // Increment level number
}
if ((! depth) || ((depth - level_nr) >= 0)
/* No depth limitation or not reached until yet */
)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert line
}
if (depth && ((depth - level_nr) == -1) && (key_nr == ETF_LEVEL)
// If level depth limitation is reached level header remains as statement.
)
{
C_ReadLine( ERR_EOF); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
if (key_nr == ETF_DUMMY
// No level header ?
)
{
StoreLine( "Text;\n", outfile);
StoreLine( "EndText;\n", outfile); // Save Text, EndText
}
else
{
bInBlockOrLevelOrFunction = TRUE;
// Set flag because text is not filtered within level headers
while (key_nr != ETF_ENDTEXT
// Multiline level header
)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
C_ReadLine( ERR_EOF);
key_nr = GetKeyword( delimiter, i_buf);
// Save line, read next and get keyword
}
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert EndText
}
}
if (key_nr == ETF_ENDLEVEL
// Keyword EndLevel ?
)
{
level_nr--; // Decrement level number
}
}
/* EasyCODE ) */
SeekPos( posNow, infile); // Reset file position to position in posNow
line_nr = act_line; // Reset actual line number
}
C_ReadLine( ERR_CCASEBRANCH); // Read next line
/* EasyCODE ( 54
Process until EndCCaseBranch of case branch */
last_key = ETF_CCASEBRANCHBODY;
// last_key dient zum Merken des zuletzt gelesenen (d.h. vor dem in key_nr gespeicherten) Schlüssels
/* EasyCODE - */
/* Lesen aller Anweisungen und Konstrukte innerhalb eines case-Zweiges */
while ((key_nr = GetKeyword(delimiter, i_buf)) != ETF_ENDCCASEBRANCH ||
((!depth) ? depth : ((depth - level_nr) < 0))
// While-Schleife wird durchlaufen, wenn Schlüssel nicht EndCCaseBranch ist oder
// wenn die zu filternde Tiefe bereits überschritten wurde
)
{
if (key_nr == ETF_LEVEL
// Keyword Level ?
)
{
level_nr += 1; // Increment level number
}
if ((! depth) || ((depth - level_nr) >= 0)
// Solange zu filternde Tiefe nicht überschritten wurde bzw. bei 0 gibt es keine Tiefenbegrenzung
)
{
if ((key_nr == ETF_DUMMY) && (last_key == ETF_CCASEBRANCHBODY)
// D.h. wenn case-Branch nichts enthält, darf das gelesene ETF_DUMMY nicht übernommen
// werden, weil anschließend ohnehin Text,Line=... , EndText
// mangels eines breaks hinausgeschrieben wird.
)
{
}
else
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert actual line
}
}
if (depth && ((depth - level_nr) == -1) && (key_nr == ETF_LEVEL)
// If level depth limitation is reached level header remains as statement.
)
{
C_ReadLine( ERR_EOF); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
if (key_nr == ETF_DUMMY
// No level header ?
)
{
StoreLine( "Text;\n", outfile);
StoreLine( "EndText;\n", outfile); // Save Text, EndText
}
else
{
bInBlockOrLevelOrFunction = TRUE;
// Set flag because text is not filtered within level headers
while (key_nr != ETF_ENDTEXT
// Multiline level header
)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
C_ReadLine( ERR_EOF);
key_nr = GetKeyword( delimiter, i_buf);
// Save line, read next and get keyword
}
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert EndText
}
}
if (key_nr == ETF_ENDLEVEL
// Keyword EndLevel ?
)
{
level_nr = level_nr - 1; // Verringern der Abschnittsanzahl
}
last_key = key_nr; // Merken des letzten Schlüssels, um zu wissen, ob ein break vor dem Ende des Zweiges war.
C_ReadLine( ERR_CCASEBRANCH); // Read next line
}
/* EasyCODE ) */
/* Read ahgead next line and convert dependent on next keyword */
C_ReadLine( ERR_CCASEBRANCH);
switch (*next_key = GetKeyword( delimiter, i_buf)
// Dependent on keyword
)
{
case ETF_CCASEBRANCH // Keyword: CCaseBranch
:
case ETF_DEFAULT // Keyword: Default
:
if (last_key != ETF_BREAK
// Last keyword before EndCCaseBranch not Break
)
{
StoreLine("Text;\n", outfile);
StoreLine("Line=Continue with next of/otherwise-branch\n",outfile);
StoreLine("EndText;\n", outfile);
// Save Text: "Continue with next of/otherwise-branch", which
// indicates that the Switch construct and the Loop is not left.
}
StoreLine("EndOnSelectorBranch;\n", outfile);
// Save keyword EndOnSelectorBranch
break;
case ETF_ENDCSWITCH // Keyword: EndSwitch
:
if (last_key != ETF_BREAK
// Last keyword before EndCCaseBranch not Break
)
{
StoreLine( "WhenExit;\n", outfile);
StoreLine( "Dummy;\n", outfile);
StoreLine( "EndWhenExit;\n", outfile);
/* Exit Loop auch even if Case branch contains no Break, because
in last branch of Switch construct it is always left. */
}
StoreLine("EndOnSelectorBranch;\n", outfile);
// Save keyword EndOnSelectorBranch
break;
}
break;
/* EasyCODE ) */
case ETF_DEFAULT // Keyword: Default
:
/* EasyCODE ( 30
Process Default */
if (*d_Begin
// If variable contains a value call is for writing the default branch
)
{
StoreLine("OnSelectorRest;\n",outfile);
StoreLine("OnSelectorBranch;\n", outfile);
StoreLine("Dummy;\n", outfile);
StoreLine("OnSelectorBranchBody;\n", outfile);
// Save keywords: OnSelectorRest,OnSelectorBranch,Dummy,OnSelectorBranchBody
/* EasyCODE - */
posNow = TellPos( infile); // Save actual file position in posNow
act_line = line_nr; // Save actual line number
if (Begin
/* Insert statement into the first and only Switch branch, the default branch */)
{
SeekPos( Begin, infile); // Set file position to start position of constructs to be inserted
line_nr = line_begin;
/* EasyCODE ( 63
Insert constructs into the Default branch */
while (TellPos( infile) != End
// While end position of constructs to be inserted not reached
)
{
C_ReadLine( ERR_DEFAULT);
key_nr = GetKeyword( delimiter, i_buf); // Read next line and get keyword
if (key_nr == ETF_LEVEL
// Keyword Level ?
)
{
level_nr += 1; // Increment level number
}
if ((! depth) || ((depth - level_nr) >= 0)
/* No depth limitation or not reached until yet */
)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert line
}
if (depth && ((depth - level_nr) == -1) && (key_nr == ETF_LEVEL)
// If level depth limitation is reached level header remains as statement.
)
{
C_ReadLine( ERR_EOF); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
if (key_nr == ETF_DUMMY
// No level header ?
)
{
StoreLine( "Text;\n", outfile);
StoreLine( "EndText;\n", outfile); // Save Text, EndText
}
else
{
bInBlockOrLevelOrFunction = TRUE;
// Set flag because text is not filtered within level headers
while (key_nr != ETF_ENDTEXT
// Multiline level header
)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
C_ReadLine( ERR_EOF);
key_nr = GetKeyword( delimiter, i_buf);
// Save line, read next and get keyword
}
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert EndText
}
}
if (key_nr == ETF_ENDLEVEL
// Keyword EndLevel ?
)
{
level_nr--; // Decrement level number
}
}
/* EasyCODE ) */
}
line_nr = default_line;
SeekPos( *d_Begin, infile); // Set start position to begin of Default branch
/* EasyCODE ( 150
Process Default content */
while ((TellPos( infile)) != *d_End
// While end position of Default branch not reached
)
{
C_ReadLine(ERR_DEFAULT); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
if (key_nr == ETF_LEVEL
// Keyword Level ?
)
{
level_nr += 1; // Increment level number
}
if ((! depth) || ((depth - level_nr) >= 0)
/* No depth limitation or not reached until yet */
)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
last_key = key_nr;
}
if (depth && ((depth - level_nr) == -1) && (key_nr == ETF_LEVEL)
// If level depth limitation is reached level header remains as statement.
)
{
C_ReadLine( ERR_EOF); // Read next line and get keyword
key_nr = GetKeyword( delimiter, i_buf);
if (key_nr == ETF_DUMMY
// No level header ?
)
{
StoreLine( "Text;\n", outfile);
StoreLine( "EndText;\n", outfile); // Save Text,EndText
}
else
{
bInBlockOrLevelOrFunction = TRUE;
// Set flag because text is not filtered within level headers
while (key_nr != ETF_ENDTEXT
// Multiline level header
)
{
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
C_ReadLine( ERR_EOF);
key_nr = GetKeyword( delimiter, i_buf);
// Save line, read next and get keyword
}
convert( key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0,&no_next_key);
// Convert EndText
}
}
if (key_nr == ETF_ENDLEVEL
// Keyword EndLevel ?
)
{
level_nr--; // Decrement level number
}
}
/* EasyCODE ) */
SeekPos( posNow, infile); // Reset file position to posNow
line_nr = act_line; // Reset to actual line number
if (last_key != ETF_BREAK
// Last keyword before EndDefault not "Break"
)
{
StoreLine( "WhenExit;\n", outfile);
StoreLine( "Dummy;\n", outfile);
StoreLine( "EndWhenExit;\n", outfile);
/* In the Default branch the Loop is always left. Therefore save
WhenExit, Dummy, EndWhenExit */
}
StoreLine("EndOnSelectorBranch;\n",outfile);
// Save EndOnSelectorBranch
/* EasyCODE - */
*d_Begin = 0; // Reset Default start and end position
*d_End = 0;
break;
}
else
{
/* .... Read branch: Get start and end position of default branch. */
/* Start position is after keyword: Default */
/* End position is before keyword: EndDefault */
*d_Begin = TellPos( infile); // Start position is line after ETF_DEFAULT
SwitchNr = 0;
while ((SwitchNr) || (key_nr != ETF_ENDDEFAULT)
/* Read until ETF_ENDDEFAULT. Only lines are processed that are on the same level.
I.e. if there are nested Switches their ENDDEFAULTs are not recognized by the
outer Switch. The program enters a read loop if no ENDDEFAULT is read and if
position is within nested Switch. */)
{
*d_End = TellPos( infile);
C_ReadLine( ERR_DEFAULT);
// Save actual position as end position and read next line. When loop is left
// the line before the keyword ETF_ENDDEFAULT remains as end position.
switch ((key_nr = GetKeyword( delimiter, i_buf))
// Dependent on keyword
)
{
case ETF_CSWITCH // Keyword: CSwitch
:
SwitchNr++; // Increment Switch number
break;
case ETF_ENDCSWITCH // Keyword: EndCSwitch
:
SwitchNr -= 1; // Decrement Switch number
break;
default:
break;
}
}
}
break;
/* EasyCODE ) */
case ETF_RETURN // Keyword: Return
:
/* EasyCODE ( 31
Process Return */
C_ReadLine( ERR_RETURN_2); // Read next line
switch (GetKeyword( delimiter, i_buf)
// Dependent on keyword
)
{
case ETF_DUMMY // Keyword: Dummy
:
StoreLine("Text;\n", outfile);
StoreLine("Line=Return\n", outfile);
StoreLine("EndText;\n", outfile);
// Save Text, Line=Return, EndText;
break;
case ETF_TEXT // Keyword: Text
:
convert( ETF_TEXT, 0, 0,0, &defaultBeginNull,&defaultEndNull,0, &no_next_key );
C_ReadLine( ERR_RETURN_2);
key_nr = GetKeyword (delimiter, i_buf);
// Convert actual line, read next line
if (key_nr == ETF_LINE
// Keyword Line
)
{
if (! bComment
// Comment filtering disabled
)
{
strcpy(result, "Line=Return ");
strcat(result, i_buf);
StoreLine( result, outfile);
*inReturn = 1;
// Assemble "Line" line to be written; before content "Return" is inserted
// Variable inReturn set to 1 to indicate that blanks have to be inserted
// in further lines.
}
else
{
*inReturn = 2;
convert(key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0, &no_next_key);
// Variable inReturn set to 2 to indicate, that "Return" has to be inserted
// in next line.
}
C_ReadLine( ERR_RETURN_2); // Read next line
while ((key_nr = GetKeyword( delimiter, i_buf)) == ETF_LINE
// While keyword: Line
)
{
/* Loop if Return value is multiline */
convert(key_nr,0,0,0,&defaultBeginNull,&defaultEndNull,0, &no_next_key);
C_ReadLine( ERR_RETURN_2);
// Convert actual line and read next
}
if (key_nr == ETF_ENDTEXT
// Next keyword: EndText ?
)
{
if (*inReturn == 2
// If Variable inReturn is still 2 theat means that no line has been written
// by the comment filter because there was no comment.
)
{
StoreLine("Line=Return\n", outfile); // Save line: Line=Return;
}
convert( key_nr, 0,0,0,&defaultBeginNull,&defaultEndNull,0, &no_next_key);
*inReturn = 0;
// Convert line with keyword EndText and reset Variable inReturn
}
else
{
err_msg( line_nr, ERR_KEYWORD); // No EndText: Error message
exit(1);
}
}
else
{
err_msg(line_nr, ERR_RETURN_1); // No Line: Error message
}
break;
default:
err_msg( line_nr, ERR_KEYWORD); // Invalid keyword: Error message
exit(1);
break;
}
break;
/* EasyCODE ) */
case ETF_ENDRETURN // Keyword: EndReturn
:
break;
case ETF_FUNCTION // Keyword: Function
:
StoreLine("Function;\n", outfile);
bInBlockOrLevelOrFunction = TRUE;
/* Save keyword Function and set flag to disable filtering of following text */
break;
case ETF_ENDFUNCTION // Keyword: EndFunction
:
StoreLine("EndFunction;\n", outfile); // Save keyword EndFunction
break;
case NO_KEYWORD // Keyword: NO_KEYWORD
:
err_msg( line_nr, ERR_NO_KEYWORD);
exit(1); // Error message and termination
break;
case ERROR_KEYWORD // Keyword: ERROR_KEYWORD
:
err_msg( line_nr, ERR_KEYWORD);
exit(1); // Error message and termination
break;
case EOF_KEYWORD // Keyword: EOF_KEYWORD
:
err_msg( line_nr, ERR_EOF);
exit(1); // Error message and termination
break;
default:
err_msg(line_nr, ERR_KEYWORD);
exit(1); // Error message and termination
break;
}
}
/* EasyCODE ) */
/* EasyCODE ( 153
control_open_file */
/* EasyCODE F */
void control_open_file (char *in_file, char *out_file, char *prog_name)
/***************************************************************************
** Function: control_open_file
** Parameters: in_file...input file
** out_file..output file
** progname..program name is expected
** Purpose: Function checks whether given files are different.
***************************************************************************/
{
if (strcmp( in_file, out_file) == 0
// Compare input and output file
)
{
fprintf(stderr, USAGEMSG, prog_name);
exit(1);
/* Error message if equal */
}
else
{
infile = OpenInput(in_file); // Open for reading
outfile = OpenOutput(out_file); // Open for writing
}
}
/* EasyCODE ) */
/* EasyCODE ( 154
find_options */
/* EasyCODE F */
int find_options (char comment[], char level[], char input[], char output[], char *prog_name)
/********************************************************************************
** Function: find_options
** Parameters: comment.....comment option is expected here
** level.......level option is expected here
** input.......input file is expected here
** output......output file is expected here
** progname....program name is is expected here
** Purpose: Checks whether "/C", "/c", "-C" or "-c" and
** level "/L=<nr>", "/l=<nr>", "-L=<nr>" or "-l=<nr>" are contained.
** If opening of files is successfull a postive number is returned.
********************************************************************************/
{
if (( (strcmp(comment, "/c") == 0) || (strcmp(comment, "-c") == 0) ||
(strcmp(comment, "/C") == 0) || (strcmp(comment, "-C") == 0) ) &&
( ((level[0] == '/') || (level[0] == '-')) &&
((level[1] == 'l') || (level[1] == 'L')) &&
(level[2] == '=') )
// Check options
)
{
bComment = TRUE; // Set flag for comment filtering.
depth = atoi( &(level[3]) ); // Convert depth filtering option to integer.
control_open_file( input, output, prog_name ); // Check and open files.
return 1;
}
else
{
return 0;
}
}
/* EasyCODE ) */
/* EasyCODE ( 32
main */
/* EasyCODE F */
main(argc,argv)
int argc;
char *argv[];
{
int key_num;
BOOL bEnd;
long def_Begin = 0L;
long def_End = 0L;
/* EasyCODE - */
level_nr = 0;
depth = 0;
bInBlockOrLevelOrFunction = FALSE;
bComment = FALSE;
*inReturn = 0;
switch (argc
// Dependent on number of arguments
)
{
case 3 // 3 arguments
:
/* Neither comment filter nor depth limit enabled */
/* EasyCODE - */
control_open_file( argv[1], argv[2], argv[0] ); // Check and open files
break;
case 4 // 4 arguments
:
if ((strcmp(argv[3], "/c") == 0) ||
(strcmp(argv[3], "-c") == 0)
// 4th argument comment filter ?
)
{
bComment = TRUE; // Set flag for comment filter
control_open_file( argv[1], argv[2], argv[0] ); // Check and open files
}
else
{
if (((argv[3][0] == '/') || (argv[3][0] == '-')) &&
(argv[3][1] == 'l') && (argv[3][2] == '=')
// 4th argument Level filter ?
)
{
depth = atoi( &(argv[3][3]) );
control_open_file( argv[1], argv[2], argv[0] );
// Convert level depth to integer, check and open files
}
else
{
if ((strcmp(argv[2], "/c") == 0) ||
(strcmp(argv[2], "-c") == 0)
// 3rd argument comment filter ?
)
{
bComment = TRUE; // Set flag for comment filter
control_open_file( argv[1], argv[3], argv[0] ); // Check and open files
}
else
{
if (((argv[2][0] == '/') || (argv[2][0] == '-')) &&
(argv[2][1] == 'l') && (argv[2][2] == '=')
// 3rd argument Level filter ?
)
{
depth = atoi( &(argv[2][3]) ); // Convert level depth to integer
control_open_file( argv[1], argv[3], argv[0] ); // Check and open files
}
else
{
if ((strcmp(argv[1], "/c") == 0) ||
(strcmp(argv[1], "-c") == 0)
// 2nd argument comment filter ?
)
{
bComment = TRUE; // Set flag for comment filter
control_open_file( argv[2], argv[3], argv[0] ); // Check and open files
}
else
{
if (((argv[1][0] == '/') || (argv[1][0] == '-')) &&
(argv[1][1] == 'l') && (argv[1][2] == '=')
// 2nd argument Level filter ?
)
{
depth = atoi( &(argv[1][3]) ); // Convert level depth to integer
control_open_file( argv[2], argv[3], argv[0] ); // Check and open files
}
else
{
fprintf(stderr, USAGEMSG, argv[0]);
exit(1);
/* Depth limit needs an additional argument */
}
}
}
}
}
}
break;
case 5 // 5 arguments
:
if (find_options(argv[1],argv[2],argv[3],argv[4],argv[0]))
{
break;
}
if (find_options(argv[1],argv[3],argv[2],argv[4],argv[0]))
{
break;
}
if (find_options(argv[1],argv[4],argv[2],argv[3],argv[0]))
{
break;
}
if (find_options(argv[2],argv[1],argv[3],argv[4],argv[0]))
{
break;
}
if (find_options(argv[3],argv[1],argv[2],argv[4],argv[0]))
{
break;
}
if (find_options(argv[4],argv[1],argv[2],argv[3],argv[0]))
{
break;
}
if (find_options(argv[3],argv[2],argv[1],argv[4],argv[0]))
{
break;
}
if (find_options(argv[4],argv[2],argv[1],argv[3],argv[0]))
{
break;
}
if (find_options(argv[2],argv[3],argv[1],argv[4],argv[0]))
{
break;
}
if (find_options(argv[2],argv[4],argv[1],argv[3],argv[0]))
{
break;
}
if (find_options(argv[3],argv[4],argv[1],argv[2],argv[0]))
{
break;
}
if (find_options(argv[4],argv[3],argv[1],argv[2],argv[0]))
{
break;
}
else
{
fprintf(stderr, USAGEMSG, argv[0]);
exit(1);
}
default:
fprintf(stderr, USAGEMSG, argv[0]);
exit(1);
break;
}
line_nr = 0; // Reset line number
/* EasyCODE ( 74
Processing loop */
while (!(bEnd = ReadLine(inbuf, infile))
// While not EOF
)
{
++line_nr; // Increment line number
key_num = GetKeyword( delimiter, i_buf); // Read keyword
if (key_num == ETF_LEVEL
// Keyword Level ?
)
{
level_nr += 1; // Increment level number
}
if ((! depth) || ((depth - level_nr) >= 0)
/* If no depth limit or not reached until yet line is converted */)
{
convert( key_num, 0,0,0,&def_Begin,&def_End,0,&no_next_key );
// Convert actual line
}
if (depth && ((depth - level_nr) == -1) && (key_num == ETF_LEVEL)
// If level depth limitation is reached level header remains as statement.
)
{
C_ReadLine( ERR_EOF); // Read next line and get keyword
key_num = GetKeyword( delimiter, i_buf);
if (key_num == ETF_DUMMY
// No level header ?
)
{
StoreLine( "Text;\n", outfile);
StoreLine( "EndText;\n", outfile);
}
else
{
bInBlockOrLevelOrFunction = TRUE;
// Set flag because text is not filtered within level headers
while (key_num != ETF_ENDTEXT
// Multiline level header
// Loop until EndText
)
{
convert( key_num, 0, 0,0,&def_Begin,&def_End,0,&no_next_key);
C_ReadLine( ERR_EOF);
key_num = GetKeyword( delimiter, i_buf);
// Convert acutal line, read next line and get keyword
}
convert( key_num, 0, 0,0,&def_Begin,&def_End,0,&no_next_key);
// Convert EndText
}
}
if (key_num == ETF_ENDLEVEL
// Keyword EndLevel ?
)
{
level_nr--; // Decrement level number
}
}
/* EasyCODE ) */
if (key_num != ETF_ENDLEVEL
// Last keyword not EndLevel ?
)
{
err_msg( line_nr, ERR_EOF ); // Error message
}
else
{
if (level_nr > 0
// Level depth still greater than 0, so Level not terminated correctly
)
{
err_msg( line_nr, ERR_EOF); // Error message
}
}
CloseFile(infile); // Close input and output file
CloseFile(outfile);
}
/* EasyCODE ) */
/* EasyCODE ) */